<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./WEB-INF/templates/turnitup_template.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core">

    <ui:define name="top">
        <ui:include src="./WEB-INF/templates/logo_bar.xhtml"/>
        <ui:include src="./WEB-INF/templates/search_bar.xhtml"/>
        <p:breadCrumb>
            <p:menuitem outcome="index"/>
            <p:menuitem value="#{webtext.search_bar}" url="#"/>
        </p:breadCrumb>
    </ui:define>

    <ui:define name="menu_left">
        <ui:include src="./WEB-INF/templates/category_menu.xhtml"/>
    </ui:define>

    <ui:define name="basket">
        <ui:include src="./WEB-INF/templates/basket_widget.xhtml"/>
    </ui:define>

    <ui:define name="content">
        <h:panelGroup layout="block" id="content_panel">
        <p:messages id="messages_search" showDetail="true" autoUpdate="true" closable="true" />
        <h:form id="search_result" styleClass="jsfcrud_list_form">
        <h:outputText escape="false" value="#{webtext.list_empty}" rendered="#{productController.items.rowCount == 0}"/>
        <h:panelGroup rendered="#{productController.items.rowCount > 0}">
                    <h:outputText value="#{productController.pagination.pageFirstItem + 1}..#{productController.pagination.pageLastItem + 1}/#{productController.pagination.itemsCount}"/>&nbsp;
                    <h:commandLink action="#{productController.previous}" value="#{webtext.previous} #{productController.pagination.pageSize}" rendered="#{productController.pagination.hasPreviousPage}"/>&nbsp;
                    <h:commandLink action="#{productController.next}" value="#{webtext.next} #{productController.pagination.pageSize}" rendered="#{productController.pagination.hasNextPage}"/>&nbsp;
                    <h:dataTable value="#{productController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{webtext.name}"/>
                            </f:facet>
                            <h:outputText value="#{item.name}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{webtext.description}"/>
                            </f:facet>
                            <h:outputText value="#{item.description}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{webtext.price}"/>
                            </f:facet>
                            <h:outputText value="#{item.price} &euro;"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{webtext.stock}"/>
                            </f:facet>
                            <h:outputText value="#{item.stock}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{webtext.image}"/>
                            </f:facet>
                            <p:graphicImage name="/images/#{item.image}" alt="#{item.image}" height="90" width="80"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandLink action="#{productController.prepareView}" value="#{webtext.view}"/>
                        </h:column>
                    </h:dataTable>
                </h:panelGroup>
        </h:form>
        </h:panelGroup>
    </ui:define>

    <ui:define name="footer">
        <ui:include src="./WEB-INF/templates/footer.xhtml"/>
    </ui:define>

</ui:composition>

